package com.project.contorller;

import com.project.bean.RoomBean;
import com.project.bean.RoomFacilityBean;
import com.project.service.IRoomFacilityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("fa")
public class RoomFacilityController {
    @Autowired
    private IRoomFacilityService service;
    @RequestMapping("findByRoomId")
    List<RoomFacilityBean> findByRoomId(Integer roomId){
       return service.findByRoomId(roomId);
    }
    @RequestMapping("addFacility")
    public String addFacility( String describe, Integer roomId){
        RoomFacilityBean roomFacilityBean = new RoomFacilityBean();
        roomFacilityBean.setDescribe(describe);
        RoomBean roomBean = new RoomBean();
        roomBean.setId(roomId);
        roomFacilityBean.setRoomBean(roomBean);
        service.addFacility(roomFacilityBean);
        return "ok";
    }
    @RequestMapping("update")
   public String update( Integer facilityId,Integer roomId){
       service.update(facilityId,roomId);
       return "ok";
    }
}
